home *** CD-ROM | disk | FTP | other *** search
/ Gigantic Games 2 / Gigantic Games 2.iso / pc / _w_ / wanderer / src / display.c < prev    next >
C/C++ Source or Header  |  1994-12-23  |  6KB  |  252 lines

  1. #include "wand_head.h"
  2.  
  3. extern int debug_disp;
  4.  
  5. /* This function is used to draw a symbol on the map, and when running
  6.  * in full-screen display mode.  Added by Alan Bland for the AMIGA to
  7.  * allow the map characters to use a color graphics font.
  8.  */
  9. void draw_map_symbol(ch)
  10. int ch;
  11. {
  12. #ifdef AMIGA
  13.     int color;
  14.     switch (ch)
  15.     {
  16.     case 'M':    color = BLUE;        break;
  17.     case 'S':    color = ORANGE;        break;
  18.     case ' ':    color = DK_GREEN;    break;
  19.     case '#':    color = DK_GRAY;    break;
  20.     case '<':    color = ORANGE;        break;
  21.     case '>':    color = ORANGE;        break;
  22.     case 'O':    color = DK_GRAY;    break;
  23.     case ':':    color = BROWN;        break;
  24.     case '/':    color = BROWN;        break;
  25.     case '\\':    color = BROWN;        break;
  26.     case '*':    color = WHITE;        break;
  27.     case '=':    color = DK_GRAY;    break;
  28.     case '@':    color = RED;        break;
  29.     case 'T':    color = YELLOW;        break;
  30.     case 'X':    color = RED;        break;
  31.     case '!':    color = BLACK;        break;
  32.     case 'C':    color = LT_GRAY;    break;
  33.     case '+':    color = LT_BLUE;    break;
  34.     case 'A':    color = RED;        break;
  35.     case '^':    color = ORANGE;        break;
  36.     default:    ch='?';color = DK_GRAY;    break;
  37.     }
  38.     set_map_font(1);
  39.     setcolor(color, DK_GREEN);
  40.     addch(ch);
  41.     setcolor(TEXT_COLOR, BACK_COLOR);
  42.     set_map_font(0);
  43. #else
  44.     addch(ch);
  45. #endif
  46. }
  47.  
  48. /* draw a box at the specified row,column,width,height */
  49. void draw_box(r,c,w,h)
  50. int r,c,w,h;
  51. {
  52. #ifdef AMIGA
  53.     /* white rectangle with dark green interior */
  54.     /* note: coordinates are text coords, must adjust for graphics */
  55.     int x1=c*8+8;
  56.     int y1=r*8+8;
  57.     int x2=x1+(w-2)*8;
  58.     int y2=y1+(h-2)*8;
  59.  
  60.     SetAPen(R, DK_GREEN);
  61.     RectFill(R, x1, y1, x2, y2);
  62.     SetAPen(R, WHITE);
  63.     Move(R, x1-1, y1-1);
  64.     Draw(R, x1-1, y2+1);
  65.     Draw(R, x2+1, y2+1);
  66.     Draw(R, x2+1, y1-1);
  67.     Draw(R, x1-1, y1-1);
  68.  
  69.     SetAPen(R, TEXT_COLOR);
  70. #else
  71.     char buf1[80], buf2[80];
  72.     int x,y;
  73.     buf1[0] = '+';
  74.     buf2[0] = '|';
  75.     for (x=1;x<w-1;++x) {
  76.         buf1[x] = '-';
  77.         buf2[x] = ' ';
  78.     }
  79.     buf1[x] = '+';
  80.     buf2[x] = '|';
  81.     buf1[x+1] = '\0';
  82.     buf2[x+1] = '\0';
  83.  
  84.     move(r,c);
  85.     addstr(buf1);
  86.     for (y=1;y<h-1;++y) {
  87.         move(r+y,c);
  88.         addstr(buf2);
  89.     }
  90.     move(r+h-1,c);
  91.     addstr(buf1);
  92. #endif
  93. }
  94.  
  95. void map(row_ptr)
  96. char (*row_ptr)[ROWLEN+1];
  97. {
  98. int  x,y;
  99. int  ch;
  100. draw_box(0,0,ROWLEN+2,NOOFROWS+2);
  101. for(y = 0;y < NOOFROWS; y++)
  102.     {
  103.     for(x = 0; x < ROWLEN; x++)
  104.     {
  105.     ch = (*row_ptr)[x];
  106.     if(!debug_disp)
  107.         {
  108.         if((ch == 'M')||(ch == 'S'))
  109.         ch = ' ';
  110.         }
  111.     else
  112.         {
  113.             if( !(ch==' '||ch=='#'||ch=='<'||ch=='>'||ch=='O'||ch==':'||
  114.               ch=='/'||ch=='\\'||ch=='*'||ch=='='||ch=='@'||ch=='T'||
  115.               ch=='X'||ch=='!'||ch=='M'||ch=='S'||ch=='C'||ch=='+'||
  116.                   ch=='A'||ch=='^') )
  117.         ch = '"';
  118.         }
  119.     /* don't bother drawing spaces - speeds up non-smart curses */
  120.     if (ch != ' ')
  121.         {
  122.         move(y+1,x+1);
  123.         draw_map_symbol(ch);
  124.         }
  125.     }
  126.     row_ptr++;
  127.     }
  128. if(!debug_disp)
  129.     {
  130.     move(18,0);
  131.     addstr("Press any key to return to the game.");
  132.     refresh();
  133.     (void) getchar();
  134.     for(y=0;y<=(NOOFROWS+2);y++)
  135.         {
  136.         move(y,0);
  137.     addstr("                                            ");
  138.     }
  139.     }
  140. else
  141.     refresh();
  142. }
  143.  
  144. /* called by scroll() and display() to actually draw the game display */
  145. void rdisplay(cx,cy,row_ptr,score)
  146. char (*row_ptr)[ROWLEN+1];
  147. int  cx,cy,score;
  148. {
  149.     int  x,y = 0,
  150.          x_coord,y_coord;
  151.     char ch;
  152.     while(y<(cy-3))
  153.     {
  154.         y++;
  155.         row_ptr++;
  156.     };
  157.     for(y=(cy-3);y<=(cy+3);y++)
  158.     {
  159.         y_coord = (y+3-cy)*2;
  160.         if ((y<0) || (y>=NOOFROWS))
  161.         {
  162. #ifdef AMIGA
  163.         /* this makes sure graphics are done right */
  164.         int i, ax;
  165.         for (ax=0,i=0; i<11; ax+=3,++i)
  166.         {
  167.             draw_symbol(ax,y_coord,'#');
  168.         }
  169. #else
  170.             move(y_coord+1,1);
  171.             addstr("#################################");
  172.             move(y_coord+2,1);
  173.             addstr("#################################");
  174. #endif
  175.         }
  176.         else
  177.     {
  178.             for(x=(cx-5);x<=(cx+5);x++)
  179.             {
  180.                 x_coord = (x+5-cx)*3;
  181.                 if ((x<0) || (x>ROWLEN-1))
  182.                     draw_symbol(x_coord,y_coord,'#');
  183.                 else
  184.                 {
  185.                     ch = (*row_ptr)[x];
  186.                     draw_symbol(x_coord,y_coord,ch);
  187.                 }
  188.             };
  189.         row_ptr++;
  190.         }                   /*   end if   */
  191.     }                       /* end y loop */
  192.     move(16,0);
  193.     refresh();
  194. }
  195.  
  196. /* draw the game display, doing intelligent scrolling if possible */
  197. /* actually, all this does is draw the display contents without */
  198. /* erasing the previous contents or redrawing the border */
  199. /* (looks better on machines that don't have intelligent curses) */
  200. /* should be possible to do nifty scrolling routines here at some point */
  201. void scroll(cx,cy,row_ptr,score)
  202. char (*row_ptr)[ROWLEN+1];
  203. int  cx,cy,score;
  204. {
  205.     /* assume border is there, just draw game display contents */
  206.     rdisplay(cx,cy,row_ptr,score);
  207. }
  208.  
  209. /* draw the game display, erasing the current contents first */
  210. void display(cx,cy,row_ptr,score)
  211. char (*row_ptr)[ROWLEN+1];
  212. int  cx,cy,score;
  213. {
  214.     /* draw the border and erase current contents of display region */
  215.     draw_box(0,0,35,16);
  216.     /* now do the actual display */
  217.     rdisplay(cx,cy,row_ptr,score);
  218. }
  219.  
  220. void redraw_screen(maxmoves,num,score,nf,diamonds,mx,sx,sy,frow)
  221. int maxmoves,num,score,nf,diamonds,mx,sx,sy;
  222. char **frow;
  223. {
  224. char buffer[50];
  225. clear();
  226. move(0,48);
  227. (void) addstr("Score\t   Diamonds");
  228. move(1,48);
  229. (void) addstr("\tFound\tTotal");
  230. move(3,48);
  231. (void) sprintf(buffer,"%d\t %d\t %d  ",score,nf,diamonds);
  232. (void) addstr(buffer);
  233. move(6,48);
  234. (void) sprintf(buffer,"Current screen %d",num);
  235. (void) addstr(buffer);
  236. if(maxmoves != 0)
  237. (void) sprintf(buffer,"Moves remaining = %d   ",maxmoves);
  238. else
  239. {
  240.     (void) strcpy(buffer,"     Unlimited moves     ");
  241.     maxmoves = -1;
  242. };
  243. move(15,48);
  244. (void) addstr(buffer);
  245. show_monster(mx != -1);           /* tell player if monster exists */
  246.  
  247. if(!debug_disp)
  248.     display(sx,sy,frow,score);
  249. else
  250.     map(frow);
  251. }
  252.